package com.evil.kingdom.pojo.entity.world.region;

import com.evil.common.mongo.entity.SingleName;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;

/**
 * 地域
 *
 * @author liyang
 * @date 2024-05-24 09:14
 */
@Getter
@Setter
@Document
public class Region implements SingleName {

    /**
     * 名称
     */
    @Id
    @NotBlank(message = "名称不能为空")
    private String name;

    /**
     * 人口
     */
    private Integer population;

    /**
     * 城防
     */
    private Double defense;

    /**
     * 金钱
     */
    private Double money;

    /**
     * X坐标
     */
    @NotNull(message = "x坐标不能为空")
    private Double x;

    /**
     * y
     */
    @NotNull(message = "y坐标不能为空")
    private Double y;

    @Override
    public String getEntityName() {
        return "地域";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Region region = (Region) o;

        return Objects.equals(name, region.name);
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
